package com.android.wellcherish.workclock;

import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.content.DialogInterface;
import android.database.Cursor;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import android.widget.TextView;
import com.android.wellcherish.workclock.util.TimeUtil;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author WellCherish
 * */

public class SearchActivity extends AppCompatActivity {

    private TextView tvDateStart, tvDateEnd;
    private ListView lv_show_records;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);

        initView();
        initConfig();
    }

    private void initView() {
        tvDateStart = findViewById(R.id.tv_date_start);
        tvDateEnd = findViewById(R.id.tv_date_end);
        lv_show_records = findViewById(R.id.lv_show_part_records);
    }

    private void initConfig() {
        tvDateStart.setOnClickListener(new View.OnClickListener() {
            @Override public void onClick(View v) {
                Calendar c = Calendar.getInstance();
                DatePickerDialog dialog =
                    new DatePickerDialog(SearchActivity.this,
                        DatePickerDialog.THEME_HOLO_LIGHT,
                        new DatePickerDialog.OnDateSetListener() {
                            @Override
                            public void onDateSet(DatePicker view, int year,
                                int month, int dayOfMonth) {
                                tvDateStart.setText(year + "-" + (month + 1)
                                    + "-" + dayOfMonth);
                            }
                        }, c.get(Calendar.YEAR), c.get(Calendar.MONTH),
                        c.get(Calendar.DAY_OF_MONTH));
                dialog.show();
            }
        });
        tvDateEnd.setOnClickListener(new View.OnClickListener() {
            @Override public void onClick(View v) {
                Calendar c = Calendar.getInstance();
                DatePickerDialog dialog =
                    new DatePickerDialog(SearchActivity.this,
                        DatePickerDialog.THEME_HOLO_LIGHT,
                        new DatePickerDialog.OnDateSetListener() {
                            @Override
                            public void onDateSet(DatePicker view, int year,
                                int month, int dayOfMonth) {
                                tvDateEnd.setText(year + "-" + (month + 1)
                                    + "-" + dayOfMonth);
                            }
                        }, c.get(Calendar.YEAR), c.get(Calendar.MONTH),
                        c.get(Calendar.DAY_OF_MONTH));
                dialog.show();
            }
        });
    }

    /**
     * 点击查询记录
     * */
    public void recordSearch(View view) {
        String start = tvDateStart.getText().toString();
        String end = tvDateEnd.getText().toString();
    }
}
